import 'package:flutter/material.dart';

import 'routing_switch_animation_route.dart';

class Chapter9Page extends StatelessWidget {
  const Chapter9Page({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("第九章"),
        leading: IconButton(
          icon: const Icon(Icons.home),
          onPressed: () => Navigator.of(context).pushNamed("/"),
        ),
      ),
      body: SingleChildScrollView(
        child: Center(
          child: Column(
            children: <Widget>[
              const SizedBox(height: 20),
              ElevatedButton(
                onPressed: () => Navigator.of(context)
                    .pushNamed("/chapter9/scale/animation"),
                child: const Text("基础动画"),
              ),
              const SizedBox(height: 20),
              ElevatedButton(
                onPressed: () => Navigator.of(context).push(
                  PageRouteBuilder(
                    transitionDuration: const Duration(seconds: 1),
                    pageBuilder: (context, animation, secondaryAnimation) {
                      return FadeTransition(
                        //使用渐隐渐入过渡,
                        opacity: animation,
                        child: const RoutingSwitchAnimationRoute(),
                      );
                    },
                  ),
                ),
                child: const Text("自定义路由切换动画"),
              ),
              const SizedBox(height: 20),
              ElevatedButton(
                onPressed: () =>
                    Navigator.of(context).pushNamed("/chapter9/hero/animation"),
                child: const Text("Hero动画"),
              ),
              const SizedBox(height: 20),
              ElevatedButton(
                onPressed: () => Navigator.of(context)
                    .pushNamed("/chapter9/stagger/animation"),
                child: const Text("交织动画"),
              ),
              const SizedBox(height: 20),
              ElevatedButton(
                onPressed: () => Navigator.of(context)
                    .pushNamed("/chapter9/animation/switcher"),
                child: const Text("AnimationSwitcher"),
              ),
              const SizedBox(height: 20),
              ElevatedButton(
                onPressed: () => Navigator.of(context)
                    .pushNamed("/chapter9/animation/decorated"),
                child: const Text("AnimationDecorated"),
              ),
              const SizedBox(height: 20),
              ElevatedButton(
                onPressed: () => Navigator.of(context)
                    .pushNamed("/chapter9/animation/widgets"),
                child: const Text("AnimationWidgets"),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
